package com.xpec.c4.service.module.task;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

//import com.xpec.c4.mobile.exception.ExceptionLog2;
import com.xpec.c4.service.module.BasicServiceModule;


/**
 * 基类
 * 
 * @author yangbingyan
 *
 */
public abstract class TaskObject {
	/**
	 * Log管理器
	 */
	private static final Log  log = LogFactory.getLog(TaskObject.class);

	/**
	 * 
	 */
	protected BasicServiceModule moduleServer;
	
	/**
	 * 
	 */
	protected Object callback;	
	
	/**
	 * 
	 * @param moduleServer
	 */
	public void setModuleServer(BasicServiceModule moduleServer) {
		this.moduleServer = moduleServer;
	}

	/**
	 * 
	 * @return
	 */
	public BasicServiceModule getModuleServer() {
		return moduleServer;
	}

	/**
	 * 模塊獲取Task時要做的事情（從Queue取出之後的事）
	 */
	public abstract void procTask() throws Exception ;
	
	/**
	 * 需自行實現調用的方法
	 * 註：异步调用结束后, 会回到原先的module, 底层会调用此方法
	 */
	public abstract void execute() throws Exception;

	public Object getCallback() {
		return callback;
	}

	public void setCallback(Object callback) {
		this.callback = callback;
	}
		
	public String getInputParametersForErrorLog() {
		return "";
	}
		
//	public String logException(Throwable t) {
//		try {
//			return ExceptionLog2.logException(t, this.getInputParametersForErrorLog());
//		} catch (Exception e) {
//			log.error("error at logging exception", e);
//		}
//		return null;
//	}
}
